package com.example.demo.controller;

import com.example.demo.entity.User;
import com.example.demo.model.RespBean;
import org.springframework.web.bind.annotation.*;

import java.util.Objects;

/**
 * @author hpp
 * @create 2021/9/14 - 14:49
 */
@RestController
public class LoginController {
//    @PostMapping("/login")
//    public RespBean Login(@RequestParam("username") String username, @RequestParam("password") String password){
//        if (!Objects.equals("admin", username) || !Objects.equals("123456", password)) {
//            String message = "账号密码错误";
//            return RespBean.ok(message);
//        } else {
//            return RespBean.ok("登录成功");
//        }
//    }
    @PostMapping("/login")
    public RespBean Login(@RequestBody User requestUser){
        String username = requestUser.getUsername();
        String password = requestUser.getPassword();
        if (!Objects.equals("admin", username) || !Objects.equals("123456", password)) {
            String message = "账号密码错误";
            return RespBean.ok(message);
        } else {
            return RespBean.error("登录成功");
        }
    }
}
